package API.DAY11.reflect;

import java.lang.reflect.Field;

public class ReflectDemo8 {
    public static void main(String[] args) throws Exception{
        Teacher teacher = new Teacher();
        teacher.name="张三";

        Class cls = Class.forName("API.DAY11.reflect.Teacher");
        Object obj = cls.newInstance();

        Field field = cls.getField("name");
        field.set(obj,"李四");
        System.out.println(obj);

        Object value = field.get(obj);
        System.out.println(value);
    }
}
